#!/bin/bash
[ "$DEVTYPE" = "partition" ]||exit 0
suuid=(${ID_FS_UUID//-/ })
gzpath="/mnt/${suuid[1]:-${suuid[0]:12}}"
devpaths=${DEVPATH%\/*}
get_sys_fs="$(df 2>/dev/null|awk '$1~/'${devpaths##*\/}'/{print $6}')"
[ "$get_sys_fs" = '/' ]&&exit 0
case "$ACTION" in
add)
[ -d "$gzpath" ]||mkdir $gzpath
systemd-mount --no-block --collect $devnode "$DEVNAME" "$gzpath"
;;
remove)
systemd-mount -u "$gzpath" 2>/dev/null
sync
rmdir $gzpath
;;
esac